﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YouHP.Model
{
    public class PrescriptionHistoryInfo : IHydratable
    {
        public int Id { get; set; }
        public int UserId { get; set; }
        public int PRId { get; set; }

        public int PrescriptionId { get; set; }
        public int ParentPrescriptionId { get; set; }
        public string PrescriptionName { get; set; }
        public int DoctorId { get; set; }
        public string DoctorName { get; set; }
        public string DoctorHospital { get; set; }
        public bool IsClassic { get; set; }
        public string PrescriptionDescription { get; set; }
        public string PrescriptionComment { get; set; }

        public int State { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public int StopReason { get; set; }
        public int UsePurpose { get; set; }
        public DateTime UpdateDate { get; set; }

        public int IsUsing { get; set; }
        public int PrescriptionHistoryId { get; set; }
       

        public PrescriptionHistoryInfo()
        {
            Id = UserId = PRId = PrescriptionId = State = StopReason = UsePurpose = -1;

            StartDate = EndDate = UpdateDate = DateTime.MaxValue;

            //Comment = Description = string.Empty;

            //IsUsing = PrescriptionHistoryId = -1;

           // UserName = PrescriptionName = string.Empty;
        }

        public PrescriptionHistoryInfo Clone()
        {
            PrescriptionHistoryInfo info = new PrescriptionHistoryInfo();
            info.Id = Id;
            info.UserId = UserId;
            info.PRId = PRId;
            info.PrescriptionId = PrescriptionId;
            info.ParentPrescriptionId = ParentPrescriptionId;
            info.PrescriptionName = PrescriptionName;

            info.DoctorId = DoctorId;
            info.DoctorName = DoctorName;
            info.DoctorHospital = DoctorHospital;

            info.IsClassic = IsClassic;
            info.PrescriptionDescription = PrescriptionDescription;
            info.PrescriptionComment = PrescriptionComment;

            info.State = State;
            info.StartDate = StartDate;
            info.EndDate = EndDate;
            info.StopReason = StopReason;
            info.UsePurpose = UsePurpose;
            info.UpdateDate = UpdateDate;

            info.IsUsing = IsUsing;
            info.PrescriptionHistoryId = PrescriptionHistoryId;

            return info;

        }

        #region IHydratable Members

        public bool Fill(System.Data.IDataReader dr)
        {
            return false;
        }

        #endregion
    }

    public class PrescriptionHistoryInfoComparer : IComparer<PrescriptionHistoryInfo>
    {
        public int Compare(PrescriptionHistoryInfo X, PrescriptionHistoryInfo Y)
        {
            return DateTime.Compare(X.StartDate, Y.StartDate);
        }

    }
}
